import { clsx, type ClassValue } from "clsx"
import { twMerge } from "tailwind-merge"

export function cn(...inputs: ClassValue[]) {
  return twMerge(clsx(inputs))
}

export function isUrl(s: string) { try { new URL(s); return true; } catch { return false; } };

export function getFileUrl(id: string) {
  return (process.env.NEXT_PUBLIC_APP_URL as string) + "/image/" + id;
}

export function image(image: string) {
  if (image) {
    return isUrl(image) ? image as string : getFileUrl(image);
  }
  return "";
}
